export default defineEventHandler(async (event) => {
  const { page = 1, pageSize = 12 } = getQuery(event)
  
  // 模拟收藏数据
  const allFavorites = [
    {
      id: 'fav1',
      userId: 'user1',
      product: {
        id: '1',
        title: 'Vue3 + Vite 后台管理系统',
        description: '基于 Vue3、Vite、TypeScript、Element Plus 的后台管理系统，包含权限管理、数据可视化等功能',
        price: 299,
        originalPrice: 599,
        cover: 'https://picsum.photos/seed/admin-system/600/400',
        category: 'frontend',
        tags: ['Vue3', 'TypeScript', 'Element Plus'],
        tech: ['Vue3', 'Vite', 'TypeScript', 'Element Plus', 'Pinia'],
        difficulty: 'intermediate' as const,
        rating: 4.8,
        reviews: 128,
        downloads: 1580,
        createdAt: '2025-01-01',
        updatedAt: '2025-01-10',
        images: ['https://picsum.photos/seed/admin-system/600/400'],
      },
      createdAt: '2025-01-15 10:00:00',
    },
    {
      id: 'fav2',
      userId: 'user1',
      product: {
        id: '2',
        title: 'React18 电商系统全栈项目',
        description: '完整的电商系统，包含用户端、管理后台、支付集成、订单管理等功能',
        price: 499,
        originalPrice: 999,
        cover: 'https://picsum.photos/seed/ecommerce/600/400',
        category: 'fullstack',
        tags: ['React', 'Node.js', 'MongoDB'],
        tech: ['React18', 'Next.js', 'Node.js', 'Express', 'MongoDB'],
        difficulty: 'advanced' as const,
        rating: 4.9,
        reviews: 256,
        downloads: 2340,
        createdAt: '2025-01-05',
        updatedAt: '2025-01-12',
        images: ['https://picsum.photos/seed/ecommerce/600/400'],
      },
      createdAt: '2025-01-14 15:30:00',
    },
    {
      id: 'fav3',
      userId: 'user1',
      product: {
        id: '3',
        title: 'Nuxt3 内容管理系统',
        description: '基于 Nuxt3 的内容管理系统，支持 Markdown、SEO 优化、多语言等功能',
        price: 399,
        originalPrice: 799,
        cover: 'https://picsum.photos/seed/cms/600/400',
        category: 'fullstack',
        tags: ['Nuxt3', 'Vue3', 'TailwindCSS'],
        tech: ['Nuxt3', 'Vue3', 'Nuxt Content', 'TailwindCSS'],
        difficulty: 'intermediate' as const,
        rating: 4.7,
        reviews: 89,
        downloads: 956,
        createdAt: '2025-01-08',
        updatedAt: '2025-01-11',
        images: ['https://picsum.photos/seed/cms/600/400'],
      },
      createdAt: '2025-01-13 09:45:00',
    },
  ]
  
  // 分页
  const pageNum = Number(page)
  const pageSizeNum = Number(pageSize)
  const start = (pageNum - 1) * pageSizeNum
  const end = start + pageSizeNum
  const items = allFavorites.slice(start, end)
  
  return {
    code: 200,
    message: 'success',
    data: {
      items,
      pagination: {
        page: pageNum,
        pageSize: pageSizeNum,
        total: allFavorites.length,
        totalPages: Math.ceil(allFavorites.length / pageSizeNum),
      },
    },
  }
})
